package top.lfyao.designpattern.details.iterator;

import java.util.ArrayList;
import java.util.List;

public class ConcreteAggregate<T> implements Aggregate<T> {

    private List<T> items = new ArrayList<>();

    @Override
    public Iterator<T> createIterator() {
        return new ConcreteIterator<T>(this);
    }
    // 集合大小
    public int count() {
       return items.size();
    }

    public T getItems(int index) {
        return items.get(index);
    }

    public void setItems(T item) {
        items.add(item);
    }

}
